<script setup name="Child" lang="ts">
const {money = 10} = defineProps<{
  username: string;
  money: number
}>()

/* const emits = defineEmits(['updateMoney', 'updateUsername'])
const updateUsername = () => {
  emits('updateUsername', '赵云')
}
const updateMoney = () => {
  emits('updateMoney', 10)
}*/
const emits = defineEmits<{
  // e: 事件名, username: 参数类型
  (e: 'updateUsername', username: '赵云' | '典韦' | '关于' | '潘凤'): void
  (e: 'updateMoney', m: number): void
}>()
const updateUsername = () => {
  emits('updateUsername', '潘凤')
}
const updateMoney = () => {
  emits('updateMoney', 10)
}
</script>
<template>
  <div>
    <p>username: {{username}}</p>
    <p>money: {{money}}</p>
    <button @click="updateUsername">update username</button>
    <button @click="updateMoney">update money</button>
  </div>
</template>
